package com.ssy.lingxi.product.api.feign;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.hystrix.CommodityHystrix;
import com.ssy.lingxi.product.api.model.request.CommodityCreditScore;
import com.ssy.lingxi.product.api.model.request.CommoditySold;
import com.ssy.lingxi.product.api.model.request.MemberRequest;
import com.ssy.lingxi.product.api.model.request.SimpleIdListRequest;
import com.ssy.lingxi.product.api.model.request.feign.CommodityPriceRequest;
import com.ssy.lingxi.product.api.model.request.feign.CommodityPublishRequest;
import com.ssy.lingxi.product.api.model.request.feign.OffPublishCommodityRequest;
import com.ssy.lingxi.product.api.model.response.BrandResponse;
import com.ssy.lingxi.product.api.model.response.channelCommodity.ChannelCommodityESResponse;
import com.ssy.lingxi.product.api.model.response.commodity.*;
import com.ssy.lingxi.product.api.model.response.feign.CommodityPriceResponse;
import com.ssy.lingxi.product.api.model.response.feign.CommoditySkuStockResponse;
import com.ssy.lingxi.product.api.model.response.store.StoreResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @menu: 商品管理--内部服务调用类
 * 商品服务内部接口
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/30
 */
@FeignClient(value = "product-service", fallback = CommodityHystrix.class)
public interface ICommodityFeign {

    /**
     * 查询商品是否用到运费模板
     * @param id 运费模板id
     * @return 是否用到
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityUseTemplate", method = RequestMethod.GET)
    Wrapper<Boolean> getCommodityUseTemplate(@RequestParam("id") Long id);

    /**
     * 查询商品是否用到发货地址
     * @param id 发货地址id
     * @return 是否用到
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityUseSendAddress", method = RequestMethod.GET)
    Wrapper<Boolean> getCommodityUseSendAddress(@RequestParam("id") Long id);

    /**
     * 查询商品是否用到物流公司
     * @param id 物流公司id
     * @return 是否用到
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityUseCompany", method = RequestMethod.GET)
    Wrapper<Boolean> getCommodityUseCompany(@RequestParam("id") Long id);

    /**
     * 查询商品是否用到单位
     * @param id 单位id
     * @return 是否用到
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityUseUnit", method = RequestMethod.GET)
    Wrapper<Boolean> getCommodityUseUnit(@RequestParam("id") Long id);

    /**
     * 批量查询商品价格
     * @param commodityPriceRequest 请求参数
     * @return key-商品skuId; value-商品价格
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityPriceBatch", method = RequestMethod.POST)
    Map<Long, Map<String, Double>> getCommodityPriceBatch(@RequestBody @Valid CommodityPriceRequest commodityPriceRequest);

    /**
     * 批量查询商品价格和是否允许使用会员权益
     * @param commodityPriceRequest 请求参数
     * @return key-商品skuId; value-是否允许使用会员价格权益+商品价格
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityPriceAndMemberPriceBatch", method = RequestMethod.POST)
    Map<Long, CommodityPriceResponse> getCommodityPriceAndMemberPriceBatch(@RequestBody @Valid CommodityPriceRequest commodityPriceRequest);

    /**
     * 通过会员品类id查询会员信息
     * @param id 会员品类id
     * @return 会员id集合
     */
    @RequestMapping(value = "/product/customer/getMemberIdList", method = RequestMethod.GET)
    Wrapper<List<Long>> getMemberIdList(@RequestParam("id") Long id);

    /**
     * 通过会员id查询会员品类和商品信息
     * @param simpleIdListRequest  请求参数
     * @return key-会员id; value-会员品类和商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityAndCategoryByMemberId", method = RequestMethod.POST)
    Map<Long, StoreResponse> getCommodityAndCategoryByMemberId(@RequestBody SimpleIdListRequest simpleIdListRequest);

    /**
     * 通过会员id和会员角色id查询会员品类和商品信息
     * @param memberRequestList  请求参数
     * @return key-会员id+会员角色id; value-会员品类和商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityAndCategoryByMemberIdAndMemberRoleId", method = RequestMethod.POST)
    Map<String, StoreResponse> getCommodityAndCategoryByMemberIdAndMemberRoleId(@RequestBody List<MemberRequest> memberRequestList);

    /**
     * 通过商品id查询商品信息
     * @param id 商品id
     * @return 商品详细信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodity", method = RequestMethod.GET)
    CommodityDetailResponse getCommodity(@RequestParam("id") Long id);

    /**
     * 通过商品skuId查询商品详情
     * @param id 商品skuId
     * @return 商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityBySkuId", method = RequestMethod.GET)
    CommodityBaseResponse getCommodityBySkuId(@RequestParam("id") Long id);

    /**
     * 查询所有已上架的商品
     * @param current 当前页码
     * @param pageSize 每页数量
     * @return 商品详细信息
     */
    @RequestMapping(value = "/product/feign/commodity/getAllOnShelfCommodity", method = RequestMethod.GET)
    PageData<CommodityDetailResponse> getAllOnShelfCommodity(@RequestParam("current") Integer current, @RequestParam("pageSize") Integer pageSize);

    /**
     * 查询渠道商品信息
     * @param id 渠道商品id
     * @return 渠道商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getChannelCommodity", method = RequestMethod.GET)
    ChannelCommodityESResponse getChannelCommodity(@RequestParam("id") Long id);

    /**
     * 查询所有已上架的渠道商品
     * @param current 当前页码
     * @param pageSize 每页数量
     * @return 渠道商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getAllOnShelfChannelCommodity", method = RequestMethod.GET)
    PageData<ChannelCommodityESResponse> getAllOnShelfChannelCommodity(@RequestParam("current") Integer current, @RequestParam("pageSize") Integer pageSize);

    /**
     * 下架某个会员的所有商品
     * @param offPublishCommodityRequest 请求参数
     * @return 是否成功
     */
    @RequestMapping(value = "/product/feign/commodity/offPublishAllCommodity", method = RequestMethod.POST)
    Wrapper<Boolean> offPublishAllCommodity(@RequestBody OffPublishCommodityRequest offPublishCommodityRequest);

    /**
     * 通过商品skuId查询对应的库存
     * @param commodityPriceRequest  请求参数
     * @return 商品skuId对应的库存
     */
    @RequestMapping(value = "/product/feign/commodity/getCommoditySkuStock", method = RequestMethod.POST)
    Wrapper<List<CommoditySkuStockResponse>> getCommoditySkuStock(@RequestBody CommodityPriceRequest commodityPriceRequest);

    /**
     * 批量查询品类信息
     * @param idList 品类id集合
     * @return 品类信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCustomerCategoryById", method = RequestMethod.POST)
    Wrapper<List<CustomerCategoryResponse>> getCustomerCategoryById(@RequestBody List<Long> idList);

    /**
     * 批量查询品牌信息
     * @param idList 品牌id集合
     * @return 品牌信息
     */
    @RequestMapping(value = "/product/feign/commodity/getBrandById", method = RequestMethod.POST)
    Wrapper<List<BrandResponse>> getBrandById(@RequestBody List<Long> idList);

    /**
     * 查询商品列表--通过商品skuId集合
     * @param commoditySkuIdList 请求参数
     * @return 商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityByCommoditySkuIdList", method = RequestMethod.POST)
    Wrapper<List<CommodityGoodsResponse>> getCommodityByCommoditySkuIdList(@RequestBody List<Long> commoditySkuIdList);

    /**
     * 查询上游供应会员商品列表--通过会员商品sku集合
     * @param commoditySkuIdList 请求参数
     * @return 上游供应会员商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getUpperCommodityByCommoditySkuIdList", method = RequestMethod.POST)
    Wrapper<List<UpperCommodityResponse>> getUpperCommodityByCommoditySkuIdList(@RequestBody List<Long> commoditySkuIdList);

    /**
     * 判断商品是否上架
     * @param commodityPublishRequest 请求参数
     * @return 是否上架成功的提示信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityIsPublish", method = RequestMethod.POST)
    Wrapper<String> getCommodityIsPublish(@RequestBody CommodityPublishRequest commodityPublishRequest);

    /**
     * 判断商品是否上架
     * @param commodityPublishRequest 查询条件实体
     * @return 上架的商品id数组
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityListByIsPublish", method = RequestMethod.POST)
    Wrapper<List<Long>> getCommodityListByIsPublish(@RequestBody CommodityPublishRequest commodityPublishRequest);

    /**
     * 更新会员商品已售数量
     * @param commoditySold 请求参数
     * @return 是否成功
     */
    @RequestMapping(value = "/product/feign/commodity/updateCommoditySold", method = RequestMethod.POST)
    Wrapper<Boolean> updateCommoditySold(@RequestBody CommoditySold commoditySold);

    /**
     * 更新渠道商品已售数量
     * @param commoditySold 请求参数
     * @return 是否成功
     */
    @RequestMapping(value = "/product/feign/commodity/updateChannelCommoditySold", method = RequestMethod.POST)
    Wrapper<Boolean> updateChannelCommoditySold(@RequestBody CommoditySold commoditySold);

    /**
     * 更新商品对应的店铺积分
     * @param commodityCreditScore 请求参数
     * @return 是否成功
     */
    @RequestMapping(value = "/product/feign/commodity/updateCommodityCreditScore", method = RequestMethod.POST)
    Wrapper<Boolean> updateCommodityCreditScore(@RequestBody CommodityCreditScore commodityCreditScore);

    /**
     * 查询商品信息列表--订单校验商品信息
     * @param commodityPriceRequest 查询条件实体
     * @return 商品信息
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityListByOrder", method = RequestMethod.POST)
    List<CommodityOrderResponse> getCommodityListByOrder(@RequestBody CommodityPriceRequest commodityPriceRequest);

    /**
     * 通过商品skuId数组查询对应的商品一级品类id
     * @param simpleIdListRequest 商品skuId数组
     */
    @RequestMapping(value = "/product/feign/commodity/getCommodityFirstCategoryIdList", method = RequestMethod.POST)
    Wrapper<List<CommoditySkuIdAndFirstCategoryIdResponse>> getCommodityFirstCategoryIdList(@RequestBody @Valid SimpleIdListRequest simpleIdListRequest);

    /**
     * 通过货品Id数组查询对应的货品一级品类id
     * @param simpleIdListRequest 货品Id数组
     */
    @RequestMapping(value = "/product/feign/commodity/getGoodsFirstCategoryIdList", method = RequestMethod.POST)
    Wrapper<List<GoodsIdAndFirstCategoryIdResponse>> getGoodsFirstCategoryIdList(@RequestBody @Valid SimpleIdListRequest simpleIdListRequest);
}
